/**
 * Copyright (c) 2015-2030 by Beijing Yanlight Co., Ltd.
 * All rights reserved.
 */
package com.yanlight.support.wx;

import com.yanlight.Constants;
import com.yanlight.support.PropertiesHolder;
import com.yanlight.type.PayType;

/**
 * @author haolw
 * @time 2017/10/26
 */
public abstract class WxConstants {
    public static final String WX_UNIFIEDORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
    public static final String WX_AUTH_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token";
    public static final String WX_AUTHORIZE_URL = "https://open.weixin.qq.com/connect/oauth2/authorize";

    //微信小微商户进件接口
    public static final String WX_MICRO_URL = "https://api.mch.weixin.qq.com/applyment/micro/submit";

    //微信小微商户证书序列号接口
    public static final String WX_MICRO_CERT = "https://api.mch.weixin.qq.com/risk/getcertficates";

    //微信发放代金券/满减的接口
    public static final String WX_COUPON = "https://api.mch.weixin.qq.com/mmpaymkttransfers/send_coupon";

    //微信红包
    public static final String WX_RED_PACKET = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack";
    //微信转账
    public static final String WX_TRANSFERS = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers";


    public static final String certPath = PropertiesHolder.get("wx.cert.path");

    //微信贷款申请后公众号通知的跳转页面
    public static final String applyMoneyCallOperate = PropertiesHolder.get("apply.money.notify");

    public static final String SIGN = "sign";
    public static final String SIGN_TYPE = "sign_type";
    public static final String WX_BASE_SCOPE = "snsapi_base";
    public static final String WX_USERINFO_SCOPE = "snsapi_userinfo";
    public static final String NOTIFY_HOST = PropertiesHolder.get("trade.notify.host");
    public static final String appId = PropertiesHolder.get("wx.appId");
    public static final String appSecret = PropertiesHolder.get("wx.appSecret");
    public static final String mchId = PropertiesHolder.get("wx.mchId");
    public static final String apiKey = PropertiesHolder.get("wx.api.key");
    public static final String authCallbackUrl = "/wx/getOpenId";
    public static final String NOTIFY_PAY_URL = "/order/notifyPay/";
    public static final String BODY_SUFFIX = "，订单号：";

    public static String getCallbackUrl() {
        return Constants.HOST + authCallbackUrl;
    }

    public static String getNotifyUrl(Integer companyId) {
        StringBuilder builder = new StringBuilder(16);
        builder.append(NOTIFY_HOST);
        builder.append(NOTIFY_PAY_URL);
        builder.append(companyId);
        builder.append(Constants.SLASH);
        builder.append(PayType.WXPAY.getType());
        return builder.toString();
    }

    public static String getBody(String name, String tradeNo) {
        return name.concat(BODY_SUFFIX).concat(tradeNo);
    }
}
